<template>
  <!-- 工单表表单弹窗 -->
  <el-dialog
    v-model="visibleDialog"
    :title="props.title"
    width="1500"
    draggable
    @close="closeDialog"
  >
    <el-form ref="formRef" label-width="80px">
      <el-row>
        <el-col :span="4">
          <el-form-item label="炉数">
            <el-input
              v-model="quantity"
              placeholder="请输入炉数"
              clearable
              @keyup.enter="getPlanWorkingForm"
            />
          </el-form-item>
        </el-col>
        <el-col :span="3">
          <el-form-item label="">
            <el-button type="primary" @click="getPlanWorkingForm"
              >验证</el-button
            >
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>

    <template #footer>
      <div class="dialog-footer">
        <el-button @click="closeDialog">取 消</el-button>
      </div>
    </template>
    <stove-descriptions
      :data="dataAll"
      :column="10"
      :isReadonly="props.isReadonly"
    />
  </el-dialog>
</template>

<script setup lang="ts">
import request from "@/utils/request";
import { useDictStoreHook } from "@/store/modules/dictionary";
import { inConsistentOne } from "@/views/mes/mesplanmonth/utilejs";
import { objectSpanMethod } from "@/views/mes/mescoremonthplan/utilejs"; // 引入
const dictionaryStore = useDictStoreHook();

defineOptions({
  name: "STOVEQUANTITYVERIFY",
  inheritAttrs: false,
});

const emit = defineEmits(["reset-table", "change-visible"]);

const props = defineProps({
  visible: {
    type: Boolean,
    default: () => {
      return false;
    },
  },
  title: {
    type: String,
    default: () => {
      return "";
    },
  },
  data: {
    type: Object,
    default: () => {
      return {};
    },
  },
  isReadonly: {
    type: Boolean,
    default: () => {
      return false;
    },
  },
});

const visibleDialog = ref(false);
const intervalDayList = ref([]);
const stoveData = ref([]);
const dataAll = ref();
watch(
  () => props.visible,
  (newVal: boolean) => {
    intervalDayList.value = props.data.intervalDayList;
    stoveData.value = props.data.stoveData;
    dataAll.value = props.data;
    visibleDialog.value = newVal;
  }
);

/** 关闭表单弹窗 */
function closeDialog() {
  visibleDialog.value = false;
  emit("change-visible", false);
  resetForm();
}

/** 重置表单 */
function resetForm() {
  intervalDayList.value = [];
  stoveData.value = [];
  quantity.value = "";
  dataAll.value.quantity = "";
  dataAll.value.intervalDayList = [];
  dataAll.value.stoveData = [];
}

// 获取当前日期yyyymmdd
function getCurrentDate() {
  const today = new Date();
  let year = today.getFullYear();
  let month = (today.getMonth() + 1).toString().padStart(2, "0");
  let day = today.getDate().toString().padStart(2, "0");
  return year.toString() + "-" + month + "-" + day;
}
const quantity = ref();
async function getPlanWorkingForm() {
  dataAll.value.quantity = quantity.value;
}
</script>
